Skip to content

feat(ui): dispatch validation events from TextField#609

Open
dmandar wants to merge 2 commits intomainfrom
feature/regex-event-clean
Open

feat(ui): dispatch validation events from TextField#609
dmandar wants to merge 2 commits intomainfrom
feature/regex-event-clean

Conversation

@dmandar
Copy link
Collaborator

@dmandar dmandar commented Feb 9, 2026

This PR introduces the a2ui-validation-input event to the
TextField
component to bubble validation state changes.

Changes
TextField (
text-field.ts
):
Added dispatch of a2ui-validation-input on every input event.
Payload: { componentId, value, valid: boolean }.
Reason: Native invalid events do not cross the Shadow DOM boundary. This custom event allows parent components (like the Shell) to observe real-time validation status.
Component Gallery (
component-gallery.ts
):
Added a listener for a2ui-validation-input at the document root.
Logs validation events to both the Console and the internal Debug Panel for visual verification.
Verification
Verified manually in the Component Gallery:
Typing in "TextField (Regex)" now triggers logs in the Debug Panel.
Valid/Invalid states strictly match the regex rules.

Pre-launch Checklist

  • [X ] I signed the CLA.
  • [ X] I read the Contributors Guide.
  • [ X] I read the Style Guide.
  • [ X] I have added updates to the CHANGELOG.
  • [ X] I updated/added relevant documentation.
  • [ X] My code changes (if any) have tests.

If you need help, consider asking for advice on the discussion board.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new a2ui-validation-input event dispatched from the TextField component to communicate validation state changes. The changes look good and achieve the goal. I've added a couple of minor suggestions to improve code style and robustness.

Copy link
Collaborator

@ditman ditman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment about having a specific, shared type for the failed/passed validation event in web_core!

return;
}

this.dispatchEvent(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation of this block seems wrong.

}

this.dispatchEvent(
new CustomEvent("a2ui-validation-input", {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be an A2UIValidationEvent extends CustomEvent, with a specific signature for the detail property, so it can be accessed safely later?

There's an example of an extension of CustomEvent here. In this case, I think the event should be in web_core, so it can be shared with other renderers; or is this a Lit-only functionality?


// Debug Validation Events
#handleValidationInput = (e: Event) => {
const detail = (e as CustomEvent).detail;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(This is where having a custom event type would help to access detail in a type-safe way)

…t catalog formatting.

This PR introduces a strictly typed A2UIValidationEvent in web_core using the BaseEventDetail pattern to ensure type safety across renderers and clients. The TextField and Component Gallery have been updated to utilize this new event structure, and formatting-only changes in standard_catalog_definition.json were reverted while preserving the new variant and filterable properties for MultipleChoice.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

2 participants